<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 
Class Dosen_Model extends Model 
{
	function Dosen_Model()
	{
		parent::Model();
	}
	
	function count_all_num_rows()
	{
		return $this->db->count_all('m_koleksi');
	}
	
	function update($id)
	{
		$data = array('approve' => '1');
		$this->db->where('id_collection', $id);
		$this->db->update('m_koleksi', $data);
		return true;
	}
	
	function get_ten_approve()
	{
		$id = $this->session->userdata('ID');
		$w = $this->db->query("SELECT A.ID_COLLECTION, D.NAMA_MAHASISWA AS NAMA_PENULIS, CASE WHEN A.APPROVE = '1' THEN 'Yes' ELSE 'No' END AS APPROVE, A.TITLE
		FROM m_koleksi A
		LEFT JOIN penulis B ON A.ID_COLLECTION = B.ID_COLLECTION
		LEFT JOIN pembimbing C ON A.ID_COLLECTION = C.ID_COLLECTION
		LEFT JOIN m_mahasiswa D ON B.NIM = D.NIM
		WHERE (A.APPROVE = '0' OR A.APPROVE is null) AND C.NIP = '".$id."' LIMIT 10");
		return $w->result();
	}
	
	
}